package BaseDatos;

import BaseDatos.DAO.Constants;
import BaseDatos.DAO.DAOFactory;
import BaseDatos.DAO.OcaDAO;
import Servidor.Modelo.Games.Game;
import Servidor.Modelo.Users.User;
import java.util.ArrayList;

/**
 * @author Angel Lopez
 */
public class FachadaBBDD {
    
    private static FachadaBBDD instance = new FachadaBBDD();
    private OcaDAO ocaDAO;
    
    private FachadaBBDD(){
        int type_factory = Constants.MYSQL; //mySQL by defect
        
        DAOFactory factoryDAO = DAOFactory.getDAOFactory(type_factory);
        
        ocaDAO = factoryDAO.getOcaDAO();
    }
    
    public static FachadaBBDD get_instance(){
        return instance;
    }
    
    
    
    // GESTION DE USUARIOS
    public int insert_user(User user) {
        
        return ocaDAO.insert_user(user);
    }

    
    public boolean delete_user(int id_user) {
        return ocaDAO.delete_user(id_user);
    }

    
    public int modificate_user(User user) {
        return ocaDAO.modificate_user(user);
    }

    
    public User select_user(int id_user) {
        return ocaDAO.select_user(id_user);
    }

    
    public ArrayList<User> select_list_users() {
        return ocaDAO.select_list_users();
    }

    
    // GESTION DE PARTIDAS
    public int insert_game(int id_owner) {
        return ocaDAO.insert_game(id_owner);
    }
    

    public boolean delete_game(int id_game) {
        return ocaDAO.delete_game(id_game);
    }


    public int update_game_date_finish() {
        return ocaDAO.update_game_date_finish();
    }

    public int update_game_winner() {
        return ocaDAO.update_game_winner();
    }

    
    public ArrayList<Game> select_list_games() {
        return ocaDAO.select_list_games();
    }

    
    
    // GESTION DE JUGADORES
    public int insert_player(int id_game, int id_player) {
        return ocaDAO.insert_player(id_game, id_player);
    }
    
    
}
